using System;
using System.Windows;
using System.Windows.Controls;

namespace FluentSilverlight.Expressions.Grid
{
    public class GridColumnExpression<TParentPart>
    {
        private readonly TParentPart parentPart;
        private readonly Action<ColumnDefinition> setValue;

        public GridColumnExpression(TParentPart parentPart, Action<ColumnDefinition> setValue)
        {
            this.parentPart = parentPart;
            this.setValue = setValue;
        }

        public TParentPart Auto()
        {
            setValue(new ColumnDefinition() {Width = new GridLength(1, GridUnitType.Auto)});
            return parentPart;
        }

        public TParentPart Star()
        {
            setValue(new ColumnDefinition() {Width = new GridLength(1, GridUnitType.Star)});
            return parentPart;
        }

        public TParentPart Width(double columnWidth)
        {
            setValue(new ColumnDefinition() {Width = new GridLength(columnWidth)});
            return parentPart;
        }
    }
}